<?php

function e($v){
  echo $v. '<br/>';
}
    class Actor{
      public $package  = array();
      public $hp = 100;
      public $mp = 1000;
      public function run(){
        e("arct move");
      }
      public function fire($monster){
        e("act:fire....");
        $monster ->hp = $monster->hp -10;
        if($monsters[0]->hp>0) {
          $monster->fire(this);
        }
      }
    public function use_equ(){
      e("use...");
    }
    public function  be_fire($x){
        $this ->hp = $this->hp-$x;
    }

}

$act1 = new Actor;
e($act1 ->hp);
$act1 ->be_fire(10);
e($act1 ->hp);
var_dump($act1);



 class Monster
 {
   public $hp = 200;
   public function run(){
     echo "monster run...";
   }
   public function fire($act){
     echo "monster fire...";
     $act ->hp = $act ->hp-5;
   }
 }
 $act = new Actor;
 $monster = array();

 for($i=0;$i<10;$i++){
   $monsters[] = new Monster;
 }

 var_dump($monsters);

for ($i=0;$i<100;$i++){
  if($monsters[0]->hp<=0){
    e("monster death");
    break;
  }
  $act->fire($monsters[0]);
}
  e("act:" . $act->hp);
  e("Monster:" . $monsters[0]->hp);
 ?>
